package router

import (
	"jgt-oper/src/context"
	"jgt-oper/src/srv"

	"github.com/facebookgo/inject"
	"github.com/teambition/gear"
)

// SrvUserMap 注册路由映射
func SrvUserMap(g *inject.Graph, r *gear.Router) {
	a := new(srv.User)
	err := g.Provide(&inject.Object{Value: a})
	if err != nil {
		panic(err)
	}

	r.Get("/users/menu", context.WrapContext(a.QuerySystemMenu))
	r.Get("/users/:id", context.WrapContext(a.Get))
	r.Get("/users/:id/function", context.WrapContext(a.QueryCommonFunction))
	r.Get("/users/search/:name", context.WrapContext(a.QueryUserByName))
	r.Post("/users", context.WrapContext(a.Create))
	r.Post("/users/app_init", context.WrapContext(a.AppInitLogin))
	r.Post("/users/:id/writeoff", context.WrapContext(a.WriteOff))
}
